﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace VRA
{
    public partial class settings : Form
    {
        public settings()
        {
            InitializeComponent();
            this.settings_read();
        }

        private void settings_read()
        {
            SqlConnectionStringBuilder sql_str = new SqlConnectionStringBuilder();
            sql_str.ConnectionString = Program.setting.ReadXml();
            this.settings_print(sql_str);
            
        }

        private void settings_print(SqlConnectionStringBuilder sql_str)
        {
            this.t_server.Text = sql_str.DataSource;
            this.t_db.Text = sql_str.InitialCatalog;
            this.t_user.Text = sql_str.UserID;
            this.t_pass.Text = sql_str.Password;
            this.cb_pers.Checked = sql_str.PersistSecurityInfo;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Program.setting.set_user_settings(this.t_server.Text, this.t_db.Text, this.t_user.Text, this.t_pass.Text, this.cb_pers.Checked);
            this.Close();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }

        private void settings_Shown(object sender, EventArgs e)
        {

        }
    }
}
